package net.iasolution.jpay.server.util

import java.net.URLDecoder;

class URLQueryParser {
	public static Hashtable getParametersOfInvocation(String url) {
		
		int idx = 0;
		Hashtable hash = new Hashtable();
		while (true) {
			int keyBegin = idx;
			int keyEnd = url.indexOf("=", idx);
			if (keyEnd == -1) {
				break;
			}
			String key = url.substring(keyBegin, keyEnd);
			int valueBegin = keyEnd + 1;
			int valueEnd = url.indexOf("&", valueBegin);
			if (valueEnd == -1) {
				valueEnd = url.length();
			}
			String value = url.substring(valueBegin, valueEnd);
			value = URLDecoder.decode(value);
			hash.put(key, value);
			idx = valueEnd + 1;

		}
		return hash;
	}
}